﻿using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.Services;
using IntelligentAgriculture.WebAPI.Application.Command.DepartMentCommand;
using IntelligentAgriculture.WebAPI.Application.Command.SheepCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.DepartMentCommandHandler
{
    public class DepartMentDeleteCommandHandler : IRequestHandler<DepartMentDeleteCommand, Results<int>>
    {

        private readonly IDepartMentService departService;
        private readonly ILogger<DepartMentDeleteCommandHandler> logger;
        public DepartMentDeleteCommandHandler(IDepartMentService departService, ILogger<DepartMentDeleteCommandHandler> logger)
        {
            this.departService = departService;
            this.logger = logger;
        }

        /// <summary>
        /// 部门删除
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Results<int>> Handle(DepartMentDeleteCommand request, CancellationToken cancellationToken)
        {
            var list = await departService.Delete(request.DepartId);
            return Results<int>.DataResult(list);
        }





    }




}
